package com.will.txj.aj.security.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @author: wen-yi;
 * @date: 2021/12/5 10:37;
 * @Description: 监听session创建的监听器
 */
@Slf4j
@Component
@WebListener
public class SessionListener implements HttpSessionListener {
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        log.info("创建session成功 -> sessionId: {}",se.getSession().getId());
        // se.getSession().setMaxInactiveInterval(5*60); //session时长5分钟
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        log.info("销毁session成功 -> sessionId: {}",se.getSession().getId());
    }
}
